﻿using System;
using UnityEngine;

namespace FrameDesign.FrameWork
{
    public class IOCExample : MonoBehaviour
    {
        private void Start()
        {
            // 创建一个 IOC 容器
            var container = new IOCContainer();
            // 根据接口注册实例
            container.Register<IBluetoothManager>(new BluetoothManager());
            // 根据接口获取蓝牙管理器的实例
            var bluetoothManager = container.Get<IBluetoothManager>();
            
            //连接蓝牙
            bluetoothManager.Connect();
        }
    }
    /// <summary>
    /// 定义接口
    /// </summary>
    public interface IBluetoothManager
    {
        void Connect();
    }
    public class BluetoothManager: IBluetoothManager
    {
        public void Connect()
        {
            Debug.Log("蓝牙连接成功");
        }
    }
}